package com.bauer.base.thread;

public class VolatileDemo {

    private static  volatile  int i;

    public static void main(String[] args) {

        for (; i < 1000; ) {
            new Thread(new Runnable() {
                @Override
                public void run() {
                    i++;
                }
            }).start();
            if(i > 1000){
                System.out.println(i);
            }
        }

        System.out.println(i);

        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
